package com.kisszoltan.android.passivity.event;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.CheckedTextView;
import android.widget.GridView;

import com.kisszoltan.android.passivity.LearnActivity;

public class LearnButtonListener implements OnClickListener {

    private GridView gridView;

    public LearnButtonListener(GridView gridView) {
        this.gridView = gridView;
    }

    public void onClick(View item) {
        Context c = item.getContext();
        List<Integer> selected = new ArrayList<Integer>();

        for (int i = 0; i < gridView.getChildCount(); i++) {
            CheckedTextView child = (CheckedTextView) gridView.getChildAt(i);

            if (child.isChecked()) {
                selected.add(i);
            }
        }

        Intent intent = new Intent(c, LearnActivity.class);
        // intent.putExtra("CATEGORIES", selected.toArray(new Integer[] {}));

        c.startActivity(intent);
    }
}
